package ch.usi.inf.pf2.cell;

import ch.usi.inf.pf2.Recognizer;
import junit.framework.TestCase;
/**
 * A RecognizerTest it tests if Recognizer class works or not.
 * 
 * @author elham.menzer@gmail.com
 */

public class RecognizerTest extends TestCase {

	
	    /**
	     * Default constructor for test class RecognizerTest
	     */
	    public RecognizerTest()
	    {
	    }

	    /**
	     * Sets up the test fixture.
	     *
	     * Called before every test case method.
	     */
	    protected void setUp()
	    {
	    }

	    /**
	     * Tears down the test fixture.
	     *
	     * Called after every test case method.
	     */
	    protected void tearDown()
	    {
	    }

	    public void testRecognizeIdentifier()
	    {
	        Recognizer recogniz1 = new Recognizer();
	        assertEquals("salam", recogniz1.recognizeIdentifier("salam khoobi manam khoobam", 0));
	        assertEquals(null, recogniz1.recognizeIdentifier(" salam khoobi manam khoobam", 0)); 
	        assertEquals("salam_khoobi", recogniz1.recognizeIdentifier("salam_khoobi manam khoobam", 0));
	        assertEquals(null, recogniz1.recognizeIdentifier("salamkhoobi 0manam khoobam", 12));
	        
	       }

	    public void testRecognizeFloatingPointNumber()
	    {
	        Recognizer recogniz1 = new Recognizer();
	        assertEquals("0.333", recogniz1.recognizeFloatingPointNumber("lablaba 0.333asdakjs", 8));
	        assertEquals("0", recogniz1.recognizeFloatingPointNumber("lablaba 0asdakjs", 8));
	        assertEquals(null, recogniz1.recognizeFloatingPointNumber("lablaba 0asdakjs", 2));
	       
	       }

	    public void testRecognizeCellRefrence()
	    {
	        Recognizer recogniz1 = new Recognizer();
	        assertEquals("A1", recogniz1.recognizeCellRefrence("A1 smdflwm ,mdfslmd", 0));
	        assertEquals("A$1", recogniz1.recognizeCellRefrence("smdflwm A$1  ,mdfslmd", 8));
	        assertEquals(null, recogniz1.recognizeCellRefrence("smdflwm $bb$1  ,mdfslmd", 8));
	        assertEquals("BB$1", recogniz1.recognizeCellRefrence("smdflwm BB$1  ,mdfslmd", 8));
	        assertEquals(null, recogniz1.recognizeCellRefrence("smdflwm BB$1  ,mdfslmd", 2));
	}
	    
	    
	    

		public void testRecognizeOpenParenthesis()
		{
			Recognizer recogniz1 = new Recognizer();
			assertEquals("(", recogniz1.recognizeOpenParenthesis("(vbnnb) xsndcsnc", 0));
		    assertEquals(null, recogniz1.recognizeOpenParenthesis("(v) xsndcsnc", 4));
	 }

		public void testRecognizeStar()
		{
			Recognizer recogniz1 = new Recognizer();
			assertEquals("*", recogniz1.recognizeStar("*sbsjdbsjdg m,sfsljg", 0));
		    assertEquals(null, recogniz1.recognizeStar("*sbsjdbsjdg m,sfsljg", 2));
	}
		
	}

